package com.atzly.community.mapper;

import com.atzly.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**   重构从mysql-redis
 * @author zlysimida
 * @date 2021/8/26 - 15:42
 */
@Mapper
@Deprecated
public interface LoginTicketMapper {

    @Insert({
            "insert into login_ticket(user_id,ticket,status,expired) ",
            "values(#{userId},#{ticket},#{status},#{expired}) "
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertTicket(LoginTicket loginTicket);

    @Select({
            "select id,user_id,ticket,status,expired ",
            "from login_ticket ",
            "where ticket=#{ticket}"
    })
    LoginTicket selectTicket(@Param("ticket") String ticket);

    @Update({
            "<script>",
            "update login_ticket set status=#{status} where ticket=#{ticket}",
            "<if test=\"ticket!=null\"> ",
            "and 1=1 ",
            "</if>",
            "</script>"
    })
    int updateTicketStatus(String ticket,int status);

    @Update({
            "update login_ticket set password=#{password},status=#{status} where ticket=#{ticket}"
    })
    int updateTicketPasswordAndStatus(String ticket, String password,int status);
}
